<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

		
	<p:tabView id = "tab">
		<p:tab title="Dados Pessoais">
			<h:panelGroup id="group_verifica_cpf" rendered="#{!pacientePessoaManager.isCpfValido}">
				<h:panelGrid columns="2">
					<h:outputText value="CPF" />
					<h:outputText value="" />
					<p:inputMask id="cpf" mask="999.999.999-99" value="#{pacientePessoaManager.paciente.pessoa.cpf}" required="true" label="CPF" converter="cpfConverter" />
					<p:commandButton value="Verificar" id="verificar_cpf" ajax="false" action="#{pacientePessoaManager.validateCpf}" />
				</h:panelGrid>
			</h:panelGroup>
		
			<h:panelGroup  rendered="#{pacientePessoaManager.isCpfValido}">
				<h:panelGrid columns="2" cellpadding="0" cellspacing="0">
					<h:outputText value="CPF" />
					<h:outputText value="Nome" />
					<p:inputMask mask="999.999.999-99" id="cpf_read" value="#{pacientePessoaManager.paciente.pessoa.cpf}" required="true" label="CPF" converter="cpfConverter" maxlength="14" readonly="true" disabled="#{pacientePessoaManager.isTelaAtendimento}"/>
					<p:inputText value="#{pacientePessoaManager.paciente.pessoa.nome}" id="nome" label="Nome" required="true" maxlength="255" style="width:400px;" disabled="#{pacientePessoaManager.isTelaAtendimento}">
						<f:validateLength maximum="255" minimum="2"/>
					</p:inputText>
				</h:panelGrid>
				
				<h:panelGrid columns="4" cellpadding="0" cellspacing="0">
					<h:outputText value="RG" />
					<h:outputText value="Nascimento" />
					<h:outputText value="Sexo" />
					<h:outputText value="Plano de Saúde"/>
					
					<p:inputText value="#{pacientePessoaManager.paciente.pessoa.rg}" maxlength="255" id="rg" label="RG" disabled="#{pacientePessoaManager.isTelaAtendimento}">
						<f:validateLength maximum="255" minimum="0"/>
					</p:inputText>
					
					<p:calendar value="#{pacientePessoaManager.paciente.pessoa.dataNascimento}" datePattern="dd/MM/yyyy" yearRange="1900" locale="pt"
								label="Data de Nascimento" id="nascimento" navigator="true" readOnlyInputText="true" disabled="#{pacientePessoaManager.isTelaAtendimento}"/>
					
					<h:selectOneRadio value="#{pacientePessoaManager.paciente.pessoa.sexo}" required="true" label="Sexo" id="sexo" disabled="#{pacientePessoaManager.isTelaAtendimento}">
						<f:selectItem itemValue="M" itemLabel="Masculino" />
						<f:selectItem itemValue="F" itemLabel="Feminino" />
					</h:selectOneRadio>
					
					<p:selectOneMenu value="#{pacientePessoaManager.paciente.planoSaude.id}" label="Plano de Saude" id="plano_saude" disabled="#{pacientePessoaManager.isTelaAtendimento}">
						<f:selectItem itemLabel="- Selecione - " />
						<f:selectItems value="#{pacientePessoaManager.listPlanoSaude}" var="ps" itemLabel="#{ps.nomePlanoSaude}" itemValue="#{ps.id}"/>
						<f:selectItem itemLabel="Não Possui" itemValue="0"/>
					</p:selectOneMenu>
					
				</h:panelGrid>
				<p:panel id="endereco"  header="Endereço">
					<ui:include src="/geral/paginas/geral/formEndereco.xhtml" />
				</p:panel>
				<p:panel id="contato" header="Contato">
					<ui:include src="/geral/paginas/geral/formTelefone.xhtml" />
				</p:panel>
			</h:panelGroup>
		</p:tab>
	</p:tabView>
	
	<p:commandButton action="#{pacientePessoaManager.save}" value="Salvar" rendered="#{pacientePessoaManager.isCpfValido and pacientePessoaManager.paciente.pessoa.id == null}" update="form" />
	<p:commandButton action="#{pacientePessoaManager.update}" value="Salvar" rendered="#{pacientePessoaManager.isCpfValido and pacientePessoaManager.paciente.pessoa.id != null}" update="form"  />
	
	
</html>